package com.google.code.mamule.mail;

import com.google.common.base.Objects;

import javax.persistence.Embeddable;

/**
 * Created with IntelliJ IDEA. User: borck_000 ; Date: 12/21/13 ; Time: 11:36 PM
 */
@Embeddable
public class Naming {

  private String salutation;
  private String givenName;
  private String surName;

  public Naming() { /* JAXB */
  }

  public Naming(final String salutation, final String givenName, final String surName) {
    this.salutation = salutation;
    this.givenName = givenName;
    this.surName = surName;
  }

  public String getSalutation() {
    return salutation;
  }

  public void setSalutation(final String salutation) {
    this.salutation = salutation;
  }

  public String getGivenName() {
    return givenName;
  }

  public void setGivenName(final String givenName) {
    this.givenName = givenName;
  }

  public String getSurName() {
    return surName;
  }

  public void setSurName(final String surName) {
    this.surName = surName;
  }

  @Override
  public String toString() {
    return Objects.toStringHelper(this)
        .add("salutation", salutation)
        .add("givenName", givenName)
        .add("surName", surName)
        .toString();
  }

  @Override
  public boolean equals(final Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    final Naming naming = (Naming) o;

    if (givenName != null ? !givenName.equals(naming.givenName) : naming.givenName != null) {
      return false;
    }
    if (salutation != null ? !salutation.equals(naming.salutation) : naming.salutation != null) {
      return false;
    }
    if (surName != null ? !surName.equals(naming.surName) : naming.surName != null) {
      return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int result = salutation != null ? salutation.hashCode() : 0;
    result = 31 * result + (givenName != null ? givenName.hashCode() : 0);
    result = 31 * result + (surName != null ? surName.hashCode() : 0);
    return result;
  }
}
